<template>
	<div class="room-default-header-wrap">
		<div class="room-default-header-inner-wrap">
			<div class="header-name-wrap fl">
				<span class="header-tag" v-if="roompara.room_qualification === '1'">实名</span>
				<span class="header-tag" v-else-if="roompara.room_qualification === '2'">认证</span>
				<span style="display: inline-block;vertical-align: top;" v-if="!speaker">等待直播</span>
				<span class="ell" style="display: inline-block;vertical-align: top;max-width: 5rem;" v-else>{{speaker}}</span>
			</div>
			<div class="real-time-people-wrap fl">
				<i class="icon-room-hot"></i>
				<span>{{allCount}}</span>
			</div>
			<div class="header-app-download-wrap" v-if="!is_official" style="display: none;">
				<a href="#">APP下载</a>
			</div>
			<div class="login-wrap" :class="{'is-android':isAndroid}">
				<span class="ell">{{user.nickname}}</span>
				<span style="display: inline-block;margin:0 2px;">|</span>
				<router-link to="/login" v-if="!user.logined">登录</router-link>
				<a href="javascript:;" @click="loginOut" v-else>退出</a>
			</div>
		</div>
	</div>
</template>

<script>
	import { mapGetters } from 'vuex'
	import { isAndroid } from '@/utils'
	export default{
		name:'DefaultHeader',
		computed:{
			...mapGetters([
			  'user',
				'allCount',
				'speaker',
				'roomLive',
				'roompara'
			])
		},
		data(){
			return{
				is_official: typeof(window.is_official) !== 'undefined' ? window.is_official : false,
				isAndroid
			}
		},
		methods:{
			loginOut(){
				this.$store.dispatch('LogOut').then(res=>{
					if(localStorage.getItem("noalertbind_"+this.user.uid)){
						localStorage.removeItem("noalertbind_"+this.user.uid)
					}
					location.reload()
				}).catch(err=>{
					console.log(err)
				})
			}
		}
	}
</script>

<style lang='scss'>
	.room-default-header-wrap{
		.login-wrap{
			position: absolute;
			right: 0.93rem;
			font-size: 1rem;
			&.is-android{
				right: 3.6rem;
			}
			span.ell{
				display: inline-block;
				max-width: 5.5rem;
				vertical-align: top;
			}
			a{
				display: inline-block;
				vertical-align: top;
			}
		}
		.room-default-header-inner-wrap{
			position: relative;
			padding: 0 1rem;
			height: 3rem;
			line-height: 3rem;
			background: rgba(0,0,0,0.25);
			color: #fff;
			font-size: 0.87rem;
			text-align: center;
			.header-name-wrap{
				font-size: 1rem;
				.header-tag{
					display: inline-block;
					width: 2.43rem;
					height: 1.25rem;
					margin-right: 0.5rem;
					line-height: 1.2rem;
					border-radius: 0.25rem;
					font-size: 0.93rem;
					color: #fff;
					background-color:#FF7900;
					text-align: center;
					vertical-align: middle;
				}
			}
			.real-time-people-wrap{
				margin: 0 0 0 4px;
				font-size: 1rem;
				.icon-room-hot{
					display: inline-block;
					width: 16px;
					height: 16px;
					background: url(../../../../../assets/images/icon-room-hot.png) no-repeat;
					background-size: contain;
					vertical-align: -2px;
					margin: 0 4px 0 0;
				}
			}
			.header-app-download-wrap{
				position: absolute;
				right:0.62rem;
				top: 50%;
				transform: translateY(-50%);
				a{
					display: block;
					width: 5.18rem;
					height: 2.12rem;
					line-height: 2.12rem;
					font-size: 0.87rem;
					color: #fff;
					background-color: #4360F0;
					border-radius: 0.25rem;
				}
			}
		}
	}
</style>
